﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using mshtml;

namespace WpfBrowserTest
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {

        public MainWindow()
        {
            InitializeComponent();

            wbMain.Navigate("http://www.facebook.de");
            
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            String strRestult = wbMain.Document.ToString();
            HTMLDocument mainDoc = (HTMLDocument)wbMain.Document;

            dynamic TST = mainDoc.childNodes;
            
            IHTMLElement ELE = mainDoc.documentElement;
            String strTest = ELE.innerHTML;

            foreach(IHTMLElement E in mainDoc.scripts)
            {
                HTMLScriptElement S = E as HTMLScriptElement;

                if(S.innerHTML != null &&
                   S.innerHTML.ToLower().Contains("var seed"))
                {
                    this.Title = "FOUND SEED!!!!!! HOOOOORRRRRAY";
                }
            }
        }


        private void wbMain_Navigating(object sender, NavigatingCancelEventArgs e)
        {
            HTMLDocument mainDoc = (HTMLDocument)wbMain.Document;
            if(mainDoc != null)
            {
                IHTMLElement ELE = mainDoc.documentElement;
                String strTest = ELE.innerHTML;
                if(strTest.ToLower().Contains("var seed"))
                {
                    this.Title = "FOUND SEED!!!!!! HOOOOORRRRRAY";
                }
            }
        }

        private void wbMain_Loaded(object sender, RoutedEventArgs e)
        {
        }

        private void wbMain_LoadCompleted(object sender, NavigationEventArgs e)
        {
        }

    }
}
